package com.zq.jichu;

/**
 * 关于String StringBuilder StringBuffer
 */
public class StringTest {
    public static void main(String[] args) throws Exception {
        //转换字符编码
        /*String s = new String("张三".getBytes(), 0,6,"UTF-8");
        System.out.println(s);*/

        //获取字符串下标所在字符
        /*String s = new String("张三是第一名！");
        System.out.println(s.charAt(1));*/

        //获取某个字符所在字符串的下标，查找字符
        /*String s = new String("张三是第一名！");
        System.out.println(s.indexOf("三"));*/

        //判断字符串是否是某个字符串开头
        /*String s = new String("张三".getBytes(), 0,3,"UTF-8");
        System.out.println(s.startsWith("张"));*/

        //判断字符串是否包含某个字串
        /*String s = new String("张三人峰".getBytes(), 0,9,"UTF-8");
        System.out.println(s.contains("三人"));*/

        String s = new String("张三人峰");
        System.out.println(s.substring(1));
        System.out.println(s.substring(1,2));
    }
}
